Telegram Group & Telegram Channel
πŸ–₯ Phi-3-mini Π² 30 строках Π½Π° C# с ONNX Runtime GenAI

Π’ Ρ€Π°ΠΌΠΊΠ°Ρ… запуска Phi-3 Microsoft выпустила ΠΎΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Π½Π½Ρ‹Π΅ ΠΌΠΎΠ΄Π΅Π»ΠΈ ONNX, ΠΊΠ°ΠΊ ΠΏΠΎΠ΄Ρ€ΠΎΠ±Π½ΠΎ описано Π² ΡΡ‚Π°Ρ‚ΡŒΠ΅ Β«ONNX Runtime supports Phi-3 mini models across platforms and devicesΒ».
Π’Π°ΠΊΠΆΠ΅ ΠΌΠΎΠ΄Π΅Π»ΠΈ Phi-3 mini ΠΎΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Π½Ρ‹ Π½Π° HuggingFace πŸ€—

Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ всё это, ΠΌΠΎΠΆΠ½ΠΎ Π»Π΅Π³ΠΊΠΎ Π·Π°ΠΏΡƒΡΡ‚ΠΈΡ‚ΡŒ модСль локально всСго Π² Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ… строках C#, ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ Π² этом Π³Π°ΠΉΠ΄Π΅.

▢️ Π“Π°ΠΉΠ΄

А Π²ΠΎΡ‚ Ρ‚Π΅ самыС 30 строк:

using Microsoft.ML.OnnxRuntimeGenAI;
var modelDirectory = args.Length == 2 ? args[1] :
@"C:\git\oss\Phi-3-mini-4k-instruct-onnx\cuda\cuda-int4-rtn-block-32";
using var model = new Model(modelDirectory);
using var tokenizer = new Tokenizer(model);
while (true)
{
Console.Write("Prompt: ");
var line = Console.ReadLine();
if (line == null) { continue; }

using var tokens = tokenizer.Encode(line);

using var generatorParams = new GeneratorParams(model);
generatorParams.SetSearchOption("max_length", 2048);
generatorParams.SetInputSequences(tokens);

using var generator = new Generator(model, generatorParams);

while (!generator.IsDone())
{
generator.ComputeLogits();
generator.GenerateNextToken();
var outputTokens = generator.GetSequence(0);
var newToken = outputTokens.Slice(outputTokens.Length - 1, 1);
var output = tokenizer.Decode(newToken);
Console.Write(output);
}
Console.WriteLine();
}


@csharp_1001_notes
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/csharp_1001_notes/456
Create:
Last Update:

πŸ–₯ Phi-3-mini Π² 30 строках Π½Π° C# с ONNX Runtime GenAI

Π’ Ρ€Π°ΠΌΠΊΠ°Ρ… запуска Phi-3 Microsoft выпустила ΠΎΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Π½Π½Ρ‹Π΅ ΠΌΠΎΠ΄Π΅Π»ΠΈ ONNX, ΠΊΠ°ΠΊ ΠΏΠΎΠ΄Ρ€ΠΎΠ±Π½ΠΎ описано Π² ΡΡ‚Π°Ρ‚ΡŒΠ΅ Β«ONNX Runtime supports Phi-3 mini models across platforms and devicesΒ».
Π’Π°ΠΊΠΆΠ΅ ΠΌΠΎΠ΄Π΅Π»ΠΈ Phi-3 mini ΠΎΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Π½Ρ‹ Π½Π° HuggingFace πŸ€—

Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ всё это, ΠΌΠΎΠΆΠ½ΠΎ Π»Π΅Π³ΠΊΠΎ Π·Π°ΠΏΡƒΡΡ‚ΠΈΡ‚ΡŒ модСль локально всСго Π² Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ… строках C#, ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ Π² этом Π³Π°ΠΉΠ΄Π΅.

▢️ Π“Π°ΠΉΠ΄

А Π²ΠΎΡ‚ Ρ‚Π΅ самыС 30 строк:


using Microsoft.ML.OnnxRuntimeGenAI;
var modelDirectory = args.Length == 2 ? args[1] :
@"C:\git\oss\Phi-3-mini-4k-instruct-onnx\cuda\cuda-int4-rtn-block-32";
using var model = new Model(modelDirectory);
using var tokenizer = new Tokenizer(model);
while (true)
{
Console.Write("Prompt: ");
var line = Console.ReadLine();
if (line == null) { continue; }

using var tokens = tokenizer.Encode(line);

using var generatorParams = new GeneratorParams(model);
generatorParams.SetSearchOption("max_length", 2048);
generatorParams.SetInputSequences(tokens);

using var generator = new Generator(model, generatorParams);

while (!generator.IsDone())
{
generator.ComputeLogits();
generator.GenerateNextToken();
var outputTokens = generator.GetSequence(0);
var newToken = outputTokens.Slice(outputTokens.Length - 1, 1);
var output = tokenizer.Decode(newToken);
Console.Write(output);
}
Console.WriteLine();
}


@csharp_1001_notes

BY C# 1001 notes





Share with your friend now:
tg-me.com/csharp_1001_notes/456

View MORE
Open in Telegram


C 1001 notes Telegram | DID YOU KNOW?

Date: |

What Is Bitcoin?

Bitcoin is a decentralized digital currency that you can buy, sell and exchange directly, without an intermediary like a bank. Bitcoin’s creator, Satoshi Nakamoto, originally described the need for β€œan electronic payment system based on cryptographic proof instead of trust.” Each and every Bitcoin transaction that’s ever been made exists on a public ledger accessible to everyone, making transactions hard to reverse and difficult to fake. That’s by design: Core to their decentralized nature, Bitcoins aren’t backed by the government or any issuing institution, and there’s nothing to guarantee their value besides the proof baked in the heart of the system. β€œThe reason why it’s worth money is simply because we, as people, decided it has valueβ€”same as gold,” says Anton Mozgovoy, co-founder & CEO of digital financial service company Holyheld.

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

C 1001 notes from kr


Telegram C# 1001 notes
FROM USA